<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>人员管理系统</title>
<jsp:include page="include.jsp"/>

<script type="text/javascript">
function playSound(src){
//alert(src);
var s = document.getElementById('snd');
//alert(s.src+"!!!");
//if(src!='' && typeof src!=undefined){
s.src = src;
//}
}

setInterval(function() {
   		
			$.ajax({
					url : '${pageContext.request.contextPath}/cnbdw/warnInfoAction!getWarnCount.action',
					dataType : 'json',
					
					success : function(result) {
						if(result==0){
							document.getElementById("green").style.display="block";
							document.getElementById("red").style.display="none";
							document.getElementById("count").style.display="none";
							
							playSound("");
							
							//document.getElementById("snd").style.display="none";
						}else{
							document.getElementById("green").style.display="none";
							document.getElementById("red").style.display="block";
							document.getElementById("count").style.display="block";
							document.getElementById("count").innerText= result;
						//	document.getElementById("snd").style.display="block";
						if(document.getElementById("silence").checked){
                                playSound("");
                             }else{
                             playSound("${pageContext.request.contextPath}/resources/1.mp3");
                             
                             }
						
						
							
						}
					}
				});	
				
				
}, 3000);







setInterval(function() {
   		$.ajax({
					url : '${pageContext.request.contextPath}/cnbdw/employeeAction!selectMonitorEmp.action',
					dataType : 'json',
					
					success : function(result) {
						if(result!=null){
						  $.messager.show({title: '提示', msg: result});
						  
						  
						  }
					//	alert(result);
						}
					
				
			});
			
}, 3000);



$(function(){
	var monitorMassage = "${monitorMassage}";
	//alert(monitorMassage+"++++!!!");
	});
    $(function() {
        <s:iterator value="#user.role.moudles" id="mdh">
        $('#<s:property value='#mdh.moudleid'/>').tree({
            url : '${pageContext.request.contextPath}/menuAction!getAllMenu.action?moudleid=<s:property value='#mdh.moudleid'/>',
            parentField : 'pid',
            lines : true,
            onClick : function(node) {
                var url;
                if (node.attributes.url) {
                    url = '${pageContext.request.contextPath}' + node.attributes.url;
                } else {
                    url = '${pageContext.request.contextPath}/error/404.jsp';
                }
                if (node.attributes.loadtype==2) {/*内部网页引入*/
                    $.messager.progress({
                        text : '页面加载中,请稍后....',
                        interval : 100
                    });
                    window.setTimeout(function() {
                        try {
                            $.messager.progress('close');
                        } catch (e) {
                        }
                    }, 500);
                    layout_center_addTabFun({
                        title : node.text,
                        closable : true,
                        iconCls : node.iconCls,
                        content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99%;"></iframe>'
                    });
                }else if(node.attributes.loadtype==3){//外部系统引入
                    $.messager.progress({
                        text : '页面加载中,请稍后....',
                        interval : 100
                    });
                    window.setTimeout(function() {
                        try {
                            $.messager.progress('close');
                        } catch (e) {
                        }
                    }, 500);
                    layout_center_addTabFun({
                        title : node.text,
                        closable : true,
                        iconCls : node.iconCls,
                        content : '<iframe src="' + node.attributes.url + '" frameborder="0" style="border:0;width:100%;height:99%;"></iframe>'
                    });
                }else if(node.attributes.loadtype==1){
                    $.messager.progress({
                        text : '页面加载中,请稍后....',
                        interval : 100
                    });
                    window.setTimeout(function() {
                        try {
                            $.messager.progress('close');
                        } catch (e) {
                        }
                    }, 500);
                    layout_center_addTabFun({
                        title : node.text,
                        closable : true,
                        iconCls : node.iconCls,
                        href : url
                    });
                }

            },
            onBeforeLoad:function(){
                $.messager.progress({
                    text : '页面加载中,请稍后....',
                    interval : 100
                });
            }
            ,
            onLoadSuccess:function(){
                $.messager.progress('close');
            }
        });
        </s:iterator>
        $('#layout_center_tabsMenu').menu({
            onClick : function(item) {
                var curTabTitle = $(this).data('tabTitle');
                var type = $(item.target).attr('type');

                if (type === 'refresh') {
                    layout_center_refreshTab(curTabTitle);
                    return;
                }

                if (type === 'close') {
                    var t = $('#layout_center_tabs').tabs('getTab', curTabTitle);
                    if (t.panel('options').closable) {
                        $('#layout_center_tabs').tabs('close', curTabTitle);
                    }
                    return;
                }

                var allTabs = $('#layout_center_tabs').tabs('tabs');
                var closeTabsTitle = [];

                $.each(allTabs, function() {
                    var opt = $(this).panel('options');
                    if (opt.closable && opt.title != curTabTitle && type === 'closeOther') {
                        closeTabsTitle.push(opt.title);
                    } else if (opt.closable && type === 'closeAll') {
                        closeTabsTitle.push(opt.title);
                    }
                });

                for ( var i = 0; i < closeTabsTitle.length; i++) {
                    $('#layout_center_tabs').tabs('close', closeTabsTitle[i]);
                }
            }
        });

        $('#layout_center_tabs').tabs({
            fit : true,
            border : false,
            onContextMenu : function(e, title) {
                e.preventDefault();
                $('#layout_center_tabsMenu').menu('show', {
                    left : e.pageX,
                    top : e.pageY
                }).data('tabTitle', title);
            },
            tools : [ {
                iconCls : 'icon-reload',
                handler : function() {
                    var href = $('#layout_center_tabs').tabs('getSelected').panel('options').href;
                    if (href) {/*说明tab是以href方式引入的目标页面*/
                        var index = $('#layout_center_tabs').tabs('getTabIndex', $('#layout_center_tabs').tabs('getSelected'));
                        $('#layout_center_tabs').tabs('getTab', index).panel('refresh');
                    } else {/*说明tab是以content方式引入的目标页面*/
                        var panel = $('#layout_center_tabs').tabs('getSelected').panel('panel');
                        var frame = panel.find('iframe');
                        try {
                            if (frame.length > 0) {
                                for ( var i = 0; i < frame.length; i++) {
                                    frame[i].contentWindow.document.write('');
                                    frame[i].contentWindow.close();
                                    frame[i].src = frame[i].src;
                                }
                                if ($.browser.msie) {
                                    CollectGarbage();
                                }
                            }
                        } catch (e) {
                        }
                    }
                }
            }, {
                iconCls : 'icon-cancel',
                handler : function() {
                    var index = $('#layout_center_tabs').tabs('getTabIndex', $('#layout_center_tabs').tabs('getSelected'));
                    var tab = $('#layout_center_tabs').tabs('getTab', index);
                    if (tab.panel('options').closable) {
                        $('#layout_center_tabs').tabs('close', index);
                    } /* else {
                     $.messager.alert('提示', '[' + tab.panel('options').title + ']不可以被关闭', 'error');
                     } */
                }
            } ]
        });
    });
    function layout_center_refreshTab(title) {
        $('#layout_center_tabs').tabs('getTab', title).panel('refresh');
    }
    function layout_center_addTabFun(opts) {
        var t = $('#layout_center_tabs');
        if (t.tabs('exists', opts.title)) {
            t.tabs('select', opts.title);
            $.messager.progress('close');
        } else {
            t.tabs('add', opts);
        }
    }
    //跳转到个人资料页面
    function editPersonDetail(){
        $('<div style="overflow:hidden"/>').dialog({
            href:'${pageContext.request.contextPath}/systemManagerAction!executeResult.action',
            width:710,
            height:500,
            modal:true,
            title:'个人资料修改',
            onClose:function(){
                window.top.$(this).dialog('destroy');
            }
        });
    }
    //注销系统
    function exitSystem(){
        window.location.href='${pageContext.request.contextPath}/userAction!logout.action';
    }
    //当页面加载成功后，执行该方法
    $(window).load(function(){
        //加载首页页面
        // $("#iframe_firstPage").attr("src","${pageContext.request.contextPath}/firstPageAction!executeFirstPage.action");
    });
    function getAllWarn(){        window.open('${pageContext.request.contextPath}/warnInfoAction!indexPage.action');
     
//    window.location.href='${pageContext.request.contextPath}/warnInfoAction!indexPage.action';

    }
    
</script>
</head>
<body class="easyui-layout">
<audio id="snd" src="" autoplay="true" playcount="-1"></audio>

<div data-options="region:'north'" style="height:75px;overflow: hidden;border:none;">
    <table style="border-top:none;" cellpadding="0" cellspacing="0"   width="100%" height="75px">
        <tr>
            <td class="linkagelogotable linkagelogo">
                                                     人员管理系统
            </td>
            <td  class="linkagelogotable">
                <table style="height:45px;float:right;margin-right:10px;" >
                    <tr>
                        <td>
                        </td>
                        <td rowspan="2" valign="middle">
                            <img alt="系统头像" title="欢迎您，${sessionInfo.username}" src="${pageContext.request.contextPath}/images/login/systemman.png" style="width:43px;height:42px;">
                        </td>
                        <td colspan="3" style="color:#ffffff" nowrap="nowrap">
                            &nbsp;&nbsp;欢迎您，${sessionInfo.username}&nbsp;&nbsp;<font style="font-size:14px">${sessionInfo.role.rolename}</font>
                        </td>
                    </tr>
                    <tr>
                    	  <td align="center" onclick="getAllWarn()">
                    	  <img id="green" src="${pageContext.request.contextPath}/images/firstpage/normal_alarm.png" style="width:22px;height:18px;vertical-align:middle"; display:none;">
                        <img id="red" src="${pageContext.request.contextPath}/images/firstpage/serious_alarm.png" style="width:22px;height:18px;vertical-align:middle"; display:none;">
                        <span id="count" style="width:30px;color: red;" />
                    		</td>
                    		
                    		<td>静音：
                    		<input id="silence"  type="checkbox" ></input>
                    		</td>
                    		
                        <td  title="查看个人资料" style="color:#ffffff;text-align:left;cursor:pointer;" nowrap="nowrap"  onclick="editPersonDetail()">&nbsp;&nbsp;<img alt="个人资料" src="${pageContext.request.contextPath}/images/login/persondetail.png" style="width:22px;height:18px;vertical-align:middle">个人资料</td>
                        <td  title="注销系统" style="color:#ffffff;text-align:left;cursor:pointer;" nowrap="nowrap" onclick="exitSystem()"><img alt="注销" src="${pageContext.request.contextPath}/images/login/exit.png" style="width:22px;height:18px;vertical-align:middle">注销</td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
<div  data-options="region:'west',title:'菜单列表',split:true" style="width: 200px;overflow: hidden;border-top:none;" >
    <div class="easyui-accordion" data-options="fit:true,border:false,animate:false">
        <s:iterator value="#user.role.moudles" id="md">

        <div  title=<s:property value='#md.moudlename'/>  data-options="tools : [ {
        iconCls : 'icon-reload',
        handler : function() {
        $('#<s:property value='#md.moudleid'/>').tree('reload');
        }
        } ]">

        <ul  id=<s:property value='#md.moudleid' /> name="framework_menu_moudle_<s:property value='#md.moudleid' />">
        </ul>
    </div>

    </s:iterator>
</div>
</div>
<div data-options="region:'center'"  style="overflow: hidden;border-top:none">
    <div id="layout_center_tabs" style="overflow: hidden;">

        <div title="首页" data-options="border:false" style="overflow: hidden;">
            <iframe id="iframe_firstPage" src="" frameborder="0" style="border: 0; width: 100%; height: 98%;"></iframe>
        </div>

    </div>
    <div id="layout_center_tabsMenu" style="width: 120px;display:none;">
        <div type="refresh">刷新</div>
        <div class="menu-sep"></div>
        <div type="close">关闭</div>
        <div type="closeOther">关闭其他</div>
        <div type="closeAll">关闭所有</div>
    </div>
</div>



</body>
</html>
